#ifndef SORTBASE_H
#define SORTBASE_H

#include <vector>
#include <QObject>
#include <QPainter>

/*
 *  Interface for all sorting method.
 *  Inherit from QObject to support signal/slot mechnism.
*/
class SortBase : public QObject
{
    Q_OBJECT
public:
    explicit SortBase(QObject *parent = nullptr);
    bool runState() const;
    void setRunState(bool state);
    void setArray(const std::vector<size_t> &given_arr);
    void randomArray(size_t num_of_elem);
    void shuffle();

public:
    // virtual function/interface for sort
    virtual void sort(size_t num_of_elem, int interval) = 0;
    virtual void stop() = 0;
    virtual void draw(QPainter *painter, int width, int height) = 0;
    virtual void skip() = 0;

signals:
    void runStateChanged(bool newState);
    void updateRequest();

public:
    std::vector<size_t> arr;

private:
    bool isRunning{false};
};

#endif // SORTBASE_H
